﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TCHSHue.BLL;
namespace TCHSHue.Modules.AdminControl.Phuong
{
    public partial class ctrPhuongList : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            NapDanhSachPhuong();
        }

        private void NapDanhSachPhuong()
        {
            var ls = PhuongBLL.getList();
            gridPhuong.DataSource = ls;
            gridPhuong.DataBind();
        }

        protected void RedirectEdit(object sender, CommandEventArgs e)
        {
            Response.Redirect("~/Modules/Admin.aspx?mode=chinhphuong&id=" + e.CommandArgument.ToString());
        }

        protected void Delete(object sender, CommandEventArgs e)
        {
            if (!PhuongBLL.delete(e.CommandArgument.ToString()))
                Page.RegisterClientScriptBlock("XoaPhuong", "<SCRIPT Language='JavaScript'> alert('Không thể xóa phường này'); </SCRIPT>");
            else
                NapDanhSachPhuong();
        }
    }
}